package com.czf.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zfChen
 * @create 2022/5/23 14:37
 */
@Configuration
public class TopicRabbitConfig {

    public final static String boy = "topic.boy";
    public final static String girl = "topic.girl";

    @Bean
    public Queue firstQueue(){
        return new Queue(TopicRabbitConfig.boy);
    }

    @Bean
    public Queue secondQueue(){
        return new Queue(TopicRabbitConfig.girl);
    }

    @Bean
    public TopicExchange exchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    public Binding bindingExchangeMessage(){
        return BindingBuilder.bind(firstQueue()).to(exchange()).with(boy);
    }

    @Bean
    public Binding bindingExchangeMessage2(){
        return BindingBuilder.bind(secondQueue()).to(exchange()).with("topic.#");
    }
}
